import Driver from 'driver.js'
import 'driver.js/dist/driver.min.css'
import { EnumLocalStorageKey } from '@/enums/localStorage'
const ShowGuide = EnumLocalStorageKey.ShowGuide
const guide = () => {
  const driver: Driver = new Driver({
    allowClose: false,
    doneBtnText: '结束',
    closeBtnText: '关闭',
    nextBtnText: '下一步',
    prevBtnText: '上一步'
  })
  driver.defineSteps(steps)
  driver.start()
}

const steps = [
  {
    element: '#language',
    popover: {
      title: 'toggle language',
      description: '切换语言',
      position: 'left'
    }
  },
  {
    element: '#settings',
    popover: {
      title: 'set app config',
      description: '设置各项配置',
      position: 'left'
    }
  }
]

export default function useGuide() {
  onMounted(() => {
    if (!localStorage.getItem(ShowGuide)) {
      guide()
      localStorage.setItem(ShowGuide, 'false')
    }
  })
}
